//
//  CLBaseNavViewController.swift
//  CLEasyBBQ
//
//  Created by simon zhao on 2017/4/12.
//  Copyright © 2017年 simon zhao. All rights reserved.
//

import UIKit

class CLBaseNavViewController: UIViewController {
    
    var leftBtn : UIButton!
    var rightBtn : UIButton!
    
    
    init(titleName:String,leftimageName:String,rightImageName:String) {
        
        super.init(nibName: nil, bundle: nil)
        
        self.navigationItem.title = titleName
        self.navigationController?.navigationBar.barTintColor = UIColor.rgbColorFromHex(rgb: 0x00bbd4)
        
        leftBtn = UIButton.init(type: .custom)
        leftBtn.frame = CGRect(x:15,y:5,width:22,height:22)
        leftBtn.setBackgroundImage(UIImage.init(named: leftimageName), for: .normal)
        leftBtn.addTarget(self, action: #selector(backToOrder), for: .touchUpInside)
        self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(customView: leftBtn)
        
        
        rightBtn = UIButton.init(type: .custom)
        rightBtn.frame = CGRect(x:0,y:0,width:22,height:22)
        rightBtn.setBackgroundImage(UIImage.init(named: rightImageName), for: .normal)
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem.init(customView: rightBtn)
        
    }
    
    
    func backToOrder(){
        
        self.navigationController?.popToRootViewController(animated: true)
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
